<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> </title>
  <script type="text/javascript" src="../js/common.js"></script>
   <link rel="stylesheet" href="../css/960.css" type="text/css" media="screen">
   <link rel="stylesheet" href="../css/screen.css" type="text/css" media="screen" />
   <link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
   <link rel="stylesheet" href="../css/print-preview.css" type="text/css" media="screen">
   <script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
   <script src="../js/find.js" type="text/javascript" charset="utf-8"></script>
   <script src="../js/utils.js" type="text/javascript" charset="utf-8"></script>
   <script type="text/javascript">
        $(function() {
           
            var nowDate = new Date();
            $("#now").html( nowDate.getFullYear()+"-"+(nowDate.getMonth() + 1)+"-"+nowDate.getDate())
            var billNO = getIdByName("billNo");
            var shopId = getIdByName("shopId");
            getSailBill(billNO,shopId)
            
         // $("#feature > div").scrollable({interval: 2000}).autoscroll();
            //$("#feature333 > div").scrollable({interval: 2000}).autoscroll();
            //$('#aside').prepend('<a class="print-preview">Print this page</a>');
         	//   $('#aside').printPreview();
            
            // Add keybinding (not recommended for production use)
           /*  $(document).bind('keydown', function(e) {
                var code = (e.keyCode ? e.keyCode : e.which);
                if (code == 80 && !$('#print-modal').length) {
                  */   $.printPreview.loadPrintPreview();
                   /*  return false;
                }            
            }); */
        });
        
        function getSailBill(billNO,shopId){
        	var param = {'billNo':billNO}
        	var SailBill = _findInfo("../saleBill/find/shopId/"+shopId+"/paid/date/0/1", param)
        	if(IsNotEmpty(SailBill)&&SailBill.state==0){
        		$("#WipeZeroAmt").html(_getIntOfJson(0, SailBill, "WipeZeroAmt"))
        		$("#ShouldAmt").html(_getIntOfJson(0, SailBill, "ShouldAmt"))
        		$("#FactAmt").html(_getIntOfJson(0, SailBill, "FactAmt"))
        		$("#FreeAmt").html(_getIntOfJson(0, SailBill, "FreeAmt"))
        		$("#standNo").html(_getStringOfJson(0, SailBill, "StandNo"))
        		$("#roomNo").html(_getStringOfJson(0, SailBill, "RoomNo"))
        		$("#Maker").html(_getStringOfJson(0, SailBill, "Maker"))
        		$("#MAKEDATE").html(_getStringOfJson(0, SailBill, "MAKEDATE"))
        		$("#billNo").html(_getStringOfJson(0, SailBill, "billNo"))
        		$("#memo").html(_getStringOfJson(0, SailBill, "Memo"))
        		$("#custName").html(_getStringOfJson(0, SailBill, "custName"))
        		$("#mp").html(_getStringOfJson(0, SailBill, "mp"))
        		$("#memberCardNo").html(_getStringOfJson(0, SailBill, "memberCardNo"))
        		$("#custName").html(_getStringOfJson(0, SailBill, "custName"))
        		$("#sum").html(_getStringOfJson(0, SailBill, "FactAmt"))
        		$("#deposit").html(_getStringOfJson(0, SailBill, "deposit"))
        		$("#cashcoup").html(_getStringOfJson(0, SailBill, "cashCouponAmount"))
        		$("#intgral").html(_getStringOfJson(0, SailBill, "integralAmount"))
        		var id= _getStringOfJson(0, SailBill, "ID");
        		if(IsNotEmpty(id)){
        			
        		
/*         			getSailBillPay(id,shopId)
 */        			var SailBillDetil = _findInfo("../saleBill/find/shopId/"+shopId+"/detl/"+id, null)
        			if(SailBillDetil.state==0){
        				loadDetil(SailBillDetil)
        			}
        			
					 var SailBillPay = _findInfo("../saleBillPay/find/sailBillPayById/"+id, null)
						if(SailBillPay.state==0){
							loadPayDetil(SailBillPay)
						}
        		}
        	}
        }
        
 /*        function getSailBillPay(id,shopId){
        	var SailBillDetil = _findInfo("../saleBillPay/find/shopId/"+shopId+"/id/"+id, null)
        	if(SailBillDetil.state ==0){
        		$("#cashAmt").html(_getIntOfJson(0, SailBillDetil, "cashAmt"))
        		$("#regAmt").html(_getIntOfJson(0, SailBillDetil, "regAmt"))
        		$("#depstAmt").html(_getIntOfJson(0, SailBillDetil, "depstAmt"))
        		$("#cashCoupAmt").html(_getIntOfJson(0, SailBillDetil, "cashCoupAmt"))
        		$("#bnkAmt").html(_getIntOfJson(0, SailBillDetil, "bnkAmt"))
        		$("#chkAmt").html(_getIntOfJson(0, SailBillDetil, "chkAmt"))
        	}
        }
         */
        function loadPayDetil(json){
        	 var cashAmt = _getIntOfJson(0, json, "cashAmt");
        	 var regAmt = _getIntOfJson(0, json, "regAmt");
        	 var depstAmt = _getIntOfJson(0, json, "depstAmt");
        	 var cashCoupAmt = _getIntOfJson(0, json, "cashCoupAmt");
        	 var bnkAmt = _getIntOfJson(0, json, "bnkAmt");
        	 var couponAmt = _getIntOfJson(0, json, "couponAmt");
        	 var integralAmt = _getIntOfJson(0, json, "integralAmt");
        	 var voucherAmt = _getIntOfJson(0, json, "voucherAmt");
        	 var voucherAmt2 = _getIntOfJson(0, json, "voucherAmt2");
        	 var voucherMemo = _getIntOfJson(0, json, "voucherMemo");
        	 var voucherMemo2 = _getIntOfJson(0, json, "voucherMemo2");
        	 $("#cashAmt").html(cashAmt)
        	 $("#regAmt").html(regAmt)
        	 $("#depstAmt").html(depstAmt)
        	 $("#cashCoupAmt").html(cashCoupAmt)
        	 $("#bnkAmt").html(bnkAmt)
        	 $("#couponAmt").html(couponAmt)
        	 $("#integralAmt").html(integralAmt)
        	 $("#voucherAmt2").html(voucherAmt2)
        	 $("#voucherAmt").html(voucherAmt)
        	         } 
         
        function loadDetil(json){
        	$("#goodsList tbody").empty();
        	for ( var i = 0; i < json.result.data.length; i++) {
        		
        		var htm="<tr>" 
        			htm+="<td>"+ _getStringOfJson(i, json, "goodsCode") +"</td>"
        			htm+="<td>"+ _getStringOfJson(i, json, "barCode") +"</td>"
        			htm+="<td>"+ _getStringOfJson(i, json, "goodsName") +"</td>"
        			var nums = _getStringOfJson(i, json, "Nums")
        			htm+="<td>"+ nums +"</td>"
        			var price =_getStringOfJson(i, json, "FactPrice")
        			htm+="<td>"+ price +"</td>"
        			
        			htm+="<td>"+ parseFloat(price*nums).toFixed(2)  +"</td>"
        			htm+="<td>"+ _getStringOfJson(i, json, "memo") +"</td>"
        			htm+="</tr>"
        				$("#goodsList tbody").append(htm);
        			}
        }

    </script>
</head>
<body>
<center>
<!-- <div class="enter"><input type="button" id="aside" value="打印" class="btn"></div><br>
 -->
<div id="printId" class="list">
	<div class="record" align="center" style="font-size: 17px;text-align: center;">销售单</div>
	<div class="record"><label><span>单号：</span><i id="billNo"></i></label><label><span>销售日期：</span><i id="MAKEDATE"></i></label><label><span>房间/车牌号：</span><i id="roomNo"></i></label></div>
	<div class="record"><label><span>会员卡号：</span><i id="memberCardNo"></i></label><label><span>姓名：</span><i id="custName"></i></label><label><span>电话：</span><i id="mp"></i></label></div>
	<div class="record"> <label><span>储值余额：</span><i id="deposit"></i></label><label><span>预付款余额：</span><i id="cashcoup"></i></label> <label><span>积分余额：</span><i id="intgral"></i></label></div>
	<div class="record">  <label><span>备注：</span><strong class="sort" id="memo"></strong></label></div>
    <table id="goodsList" class="tb1" width="100%" cellpadding="1" cellspacing="0" border="1" bordercolor="#fff">
    	<thead>
        	<tr>
            	<th>商品编码</th>
            	<th>商品条码</th>
            	<th>商品名称</th>
            	<th>数量</th>
            	<th>单价</th>
            	<th>小计</th>
            	<th>备注</th>
            </tr>
        </thead>
        <tbody>
        
        </tbody>
    </table>
 </br>
        	<div class="record"><label><span>免单：</span><i id="FreeAmt"></i></label><label><span>抹零：</span><i id="WipeZeroAmt"></i></label></div>
    	<div class="record"><label><span>总计：</span><i id="sum"></i></label></div>
        	<div class="record"><label><span>付款方式：</span></label></div>
        	
 			<div class="record"><label><span>现金：</span><i id="cashAmt"></i></label><label><span>挂账：</span><i id="regAmt"></i></label></div>
 			<div class="record"><label><span>储值：</span><i id="depstAmt"></i></label><label><span>POS付款：</span><i id="bnkAmt"></i></label></div>
         	<div class="record"><label><span>预付款：</span><i id="cashCoupAmt"></i></label><label><span>积分抵现：</span><i id="integralAmt"></i></label></div>
         	<div class="record"><label><span>材料抵扣：</span><i id="voucherAmt"></i></label><label><span>工时抵扣：</span><i id="voucherAmt2"></i></label></div>

	<div class="record"><label><span>经办人：</span><i id="Maker"></i></label><label><span>打票日期：</span><i id="now"></i></label><label><span>客户签字：</span><i></i></label></div>
    <div class="record"  style="height:10px;"></div>
</div>
</center>

</body>
<!-- <script language="JavaScript">
 var hkey_key;
 var hkey_root="HKEY_CURRENT_USER";
 var hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
 //设置网页打印的页眉页脚为空
 function pagesetup_null()
 {
 
  var RegWsh = new ActiveXObject("WScript.Shell");
 hkey_key="header";
 RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
 hkey_key="footer";
 RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");

}

//设置网页打印的页眉页脚为默认值
function pagesetup_default()
{
 try{
 var RegWsh = new ActiveXObject("WScript.Shell");
 hkey_key="header";
 RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码，&p/&P");
 hkey_key="footer";
 RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d");
 }catch(e){}
}
</script>  -->
   <script src="../js/jquery.print-preview.js" type="text/javascript" charset="utf-8"></script>

<style type="text/css">
.tb1 td,.tb1 th{text-align:center;padding:2px 3px;}
.list{width:600px;}
.enter .btn{padding:4px 14px;background-color:#0079BA;border:none;font-size:14px;font-family:Microsoft Yahei;color:#fff;border-radius:3px;}
</style>
</html>